from flask import Flask, render_template, jsonify
import os
from datetime import datetime
import json
from temperature_monitor import TemperatureMonitor

app = Flask(__name__)

# 初始化温度监控器
monitor = TemperatureMonitor(
    data_root="/data/work/data/test",
    hostip_path="/data/work/temp_test/hostip"
)

@app.route('/')
def index():
    # 显示历史温度列表
    history_data = monitor.get_history_data()
    return render_template('index.html', history=history_data)

@app.route('/day/<date>')
def day_temperature(date):
    # 显示某天的温度曲线
    day_data = monitor.get_day_data(date)
    return render_template('day.html', date=date, cameras=day_data)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)
